package com.bto.solar.work.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author Administrator
 */
@Slf4j
@Service
public class BtoReconnaissanceService {
//    @Autowired
//    private BtoUserService btoUserService;
//    @Autowired
//    private ApprovalManager approvalManager;
//    @Autowired
//    private IReconnaissanceService reconnaissanceService;
//    @Autowired
//    private IOrdersService ordersService;
//
//    /**
//     * 审核列表分页查询
//     */
//    public Page<ReconnaissanceVO> getReconnaissancePage(Integer currentPage, Integer pageSize,
//                                                        String stage, String nameOrOn, String nameOrPhone) {
//
//        //如果是approval为true, 如果是reconnaissance为false
//        boolean approvalOrReconnaissance = false;
//
//        List<Orders> orders = approvalManager.getOrdersByApprovalOrReconnaissance(approvalOrReconnaissance);
//        if (orders == null) {
//            return new Page<>();
//        }
//
//        Set<Long> orderIds = approvalManager.getOrderByQuery(orders, nameOrOn, nameOrPhone, approvalOrReconnaissance);
//        if (null == orderIds) {
//            return new Page<>();
//        }
//
//
//        Page<Reconnaissance> reconnaissancePage = new Page<>(currentPage, pageSize);
//        reconnaissanceService.getReconnaissancePage(orderIds, stage, reconnaissancePage);
//
//        Page<ReconnaissanceVO> reconnaissanceVoPage = new Page<>();
//        BeanUtils.copyProperties(reconnaissancePage, reconnaissanceVoPage);
//        List<ReconnaissanceVO>  reconnaissanceVoArrayList = new ArrayList<>();
//        reconnaissancePage.getRecords().forEach(reconnaissance -> {
//            ReconnaissanceVO reconnaissanceVO = new ReconnaissanceVO();
//            BeanUtils.copyProperties(reconnaissance, reconnaissanceVO);
//            //JSONArray
//            reconnaissanceVO.setApproval(JSONArray.parse(reconnaissance.getApproval()));
//            reconnaissanceVO.setReasonImages(JSONArray.parse(reconnaissance.getReasonImages()));
//            reconnaissanceVO.setReasonVideos(JSONArray.parse(reconnaissance.getReasonVideos()));
//            reconnaissanceVO.setReasonFiles(JSONArray.parse(reconnaissance.getReasonFiles()));
//            reconnaissanceVO.setLeaseBody(JSONObject.parse(reconnaissance.getLeaseBody()));
//
//            Orders dbOrder = ordersService.getById(reconnaissance.getOrderId());
//            Users dbUser = btoUserService.getUserByUserId(dbOrder.getUserId());
//
//            if (NullUtils.isAnyNull(dbOrder, dbOrder)) {
//                throw new BizException(BizCode.PARAM_ERROR);
//            }
//
//            ReconnaissanceVO.OrderDTO orderDTO = new ReconnaissanceVO.OrderDTO();
//            orderDTO.setId(dbOrder.getId()).setName(dbOrder.getName()).setNo(dbOrder.getNo())
//                    .setUserId(dbOrder.getUserId()).setCategoryId(dbOrder.getCategoryId());
//            orderDTO.setUser(new ReconnaissanceVO.OrderDTO.UserDTO().setId(dbOrder.getId()).setName(dbUser.getName()));
//            reconnaissanceVO.setOrder(orderDTO);
//
//
//            reconnaissanceVoArrayList.add(reconnaissanceVO);
//
//        });
//        reconnaissanceVoPage.setRecords(reconnaissanceVoArrayList);
//
//        return reconnaissanceVoPage;
//    }

}
